package Index_PKG;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet
	{
		private static final long serialVersionUID = 1L;
		private PrintWriter out;

		protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
			{
				doPost(request, response);
			}

		protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
			{
				out = response.getWriter();

				HtmlGenerator.createBodyHeadHtml(out, "./CSS/StyleSheet.css", "Login", "./JavaScript/gestion.js");

				// HtmlGenerator.createBodyHeadHtml(out, "./CSS/StyleSheet.css",
				// "Login");

				HtmlGenerator.createFormulaire(out, "Authentification");

				// TABLE LOGIN
				HtmlGenerator.createTable(out, null, "Tab_Login");

				// LIGNE LOGIN
				HtmlGenerator.createTableRow(out, "TR_Login");

				HtmlGenerator.createTableColumn(out, null, "TD_Login");
				HtmlGenerator.createText(out, "Login :");
				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.createTableColumn(out, null, "TD_TB_Login");
				HtmlGenerator.createTextBox(out, "TB_Login", "TB_Login", null, null, "");

				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.closeTableRow(out);

				// LIGNE PASSWORD
				HtmlGenerator.createTableRow(out, "TR_Password");

				HtmlGenerator.createTableColumn(out, null, "TD_Password");
				HtmlGenerator.createText(out, "Password :");
				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.createTableColumn(out, null, "TD_TB_Password");
				HtmlGenerator.createTextBox(out, "TB_Password", "TB_Password", null, null, "");
				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.closeTableRow(out);

				// LIGNE BOUTON VALIDER
				HtmlGenerator.createTableRow(out, "TR_Empty");

				HtmlGenerator.createTableColumn(out, null, "TD_Empty");
				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.createTableColumn(out, null, "TD_BT_Login");
				HtmlGenerator.createSubmitButton(out, "Login", "BT_Login", "onmouseover=\"ChangeButtonColor(this);\"  onmouseout=\"ReinitButtonColor(this);\"");
				HtmlGenerator.closeTableColumn(out);

				HtmlGenerator.closeTableRow(out);

				// FIN TABLE LOGIN
				HtmlGenerator.closeTable(out);

				HtmlGenerator.closeFormulaire(out);

				if (request.getAttribute("errors") != null)
					HtmlGenerator.createText(out, request.getAttribute("errors").toString());

				HtmlGenerator.closeEndBodyHeadHtml(out);

			}

	}
